﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zocono.WCS.Domain.PlcBytesObject
{
    public class PlanarPutBatteryPlcActionBO : BytesObjectBase
    {

        /// <summary>
        /// 请求读取电池条码握手   
        /// </summary>
        public short ActionType { get; set; }
        /// <summary>
        /// 电池位置
        /// </summary>
        public short BatteryIndex { get; set; }
        /// <summary>
        /// 托盘条码
        /// </summary>
        public string PalletBarcode { get; set; }

        /// <summary>
        /// 电池条码
        /// </summary>
        public string BatteryCode { get; set; }

        /// <summary>
        /// 目标位置编号
        /// </summary>
        public int ToEquipmentCode { get; set; }
        public int TaskCode { get; set; }
        public override void Serialize(long plcConnectionID, long plcReadDbID, int bytesIndex, int bytesLength, int objectIndex, int objectLength, string objectType, string ScEquipmentCode, byte[] bytes)
        {

            PlcConnectionID = plcConnectionID;
            PlcReadDbID = plcReadDbID;
            BytesIndex = bytesIndex;
            BytesLength = bytesLength;
            ObjectIndex = objectIndex;
            ObjectLength = objectLength;
            ObjectType = objectType;

            EquipmentCode = HelperByte.GetDIntAt(bytes, 0).ToString();
            BatteryIndex = HelperByte.GetIntAt(bytes, 4);
            int length1 = HelperByte.GetSIntAt(bytes, 7);
            PalletBarcode = HelperByte.GetCharsAt(bytes, 8, length1);
            int length2 = HelperByte.GetSIntAt(bytes, 27);
            BatteryCode = HelperByte.GetCharsAt(bytes, 28, length2);
            //ToEquipmentCode = HelperByte.GetDIntAt(bytes, 62);
            //TaskCode = HelperByte.GetDIntAt(bytes, 66);
        }
    }
}
